package com.zhangxin.designmode.fiveprinciple.openclosedprinciple.after;

import com.zhangxin.designmode.fiveprinciple.openclosedprinciple.before.NotificationEmergencyLevel;

/**
 * @author zhangxin
 * @date 2022/4/9
 */
public class TimeoutAlertHandler extends AlertHandler {

    public TimeoutAlertHandler(AlertRule alertRule, Notification notification) {
        super(alertRule, notification);
    }

    @Override
    public void check(ApiStatInfo apiStatInfo) {
        if (apiStatInfo.getTimeoutCount() / apiStatInfo.getDurationOfSeconds() > alertRule.getMatchedRule(apiStatInfo.getApi()).getMaxTimeoutTps()) {
            notification.notify(NotificationEmergencyLevel.URGENCY.getInfo(), "...");
        }
    }
}
